package com.heyqing.topic.IsPalindrome_0234;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * ClassName:IsPalindrome
 * Package:com.heyqing.topic.IsPalindrome_0234
 * Description:
 *
 * @Date:2024/9/24
 * @Author:Heyqing
 */
public class IsPalindrome {
    public boolean isPalindrome(ListNode head) {
        List<Integer> nodeList = new ArrayList<>();
        while (Objects.nonNull(head)) {
            nodeList.add(head.val);
            head = head.next;
        }
        for (int i = 0; i < (nodeList.size()) / 2; i++) {
            if(nodeList.get(i) != nodeList.get(nodeList.size() - 1 -i)) return false;
        }
        return true;
    }

}
